<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>修改用户余额</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="/web/res/css/xadmin.css">
    <script src="/web/res/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/web/res/js/xadmin.js"></script>
</head>
<body style="background-color: white;">
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <form class="layui-form layui-form-pane" id="formsubmit" style="margin:20px auto" action="/">
                <input type="hidden" id="id" name="id" value="${(user.id?c)!''}">
                <fieldset class="layui-elem-field layui-field-title">
                    <legend><strong>用户基本资料</strong></legend>
                </fieldset>
                <div class="layui-form-item ">
                    <label class="layui-form-label" style="width: 150px;">用户手机号</label>
                    <div class="layui-input-inline">
                        <input type="text" style="width:80%;" readonly class="layui-input"
                               value="${(user.loginname)!''}" disabled/>
                    </div>
                </div>
                <div class="layui-form-item ">
                    <label class="layui-form-label" style="width: 150px;">用户昵称</label>
                    <div class="layui-input-inline">
                        <input type="text" style="width:80%;" readonly class="layui-input" value="${(user.nick)!''}"
                               disabled/>
                    </div>
                </div>
                <div class="layui-form-item ">
                    <label class="layui-form-label" style="width: 150px;">用户账号</label>
                    <div class="layui-input-inline">
                        <input type="text" style="width:80%;" readonly class="layui-input" value="${(user.usercode?c)!''}"
                               disabled/>
                    </div>
                </div>
                <div class="layui-form-item ">
                    <label class="layui-form-label" style="width: 150px;">用户头像</label>
                    <div class="layui-input-inline">
                        <img style="width:50px;" src="${(user.pic)!''}" disabled/>
                    </div>
                </div>
                <div class="layui-form-item ">
                    <label class="layui-form-label" style="width: 150px;">用户持有金币</label>
                    <div class="layui-input-inline">
                        <input type="number" style="width:80%;" readonly class="layui-input"
                               value="${(user.jinbi?c)!''}" disabled/>
                    </div>
                </div>
                <div class="layui-form-item ">
                    <label class="layui-form-label" style="width: 150px;">用户持有钻石</label>
                    <div class="layui-input-inline">
                        <input type="number" style="width:80%;" readonly class="layui-input"
                               value="${(user.diamonds?c)!''}" disabled/>
                    </div>
                </div>
                <div class="layui-form-item ">
                    <label class="layui-form-label" style="width: 150px;">用户持有魅力值</label>
                    <div class="layui-input-inline">
                        <input type="number" style="width:80%;" readonly class="layui-input"
                               value="${(user.charmvalue?c)!''}" disabled/>
                    </div>
                </div>
                <fieldset class="layui-elem-field layui-field-title">
                    <legend><strong>金币金额修改</strong></legend>
                </fieldset>
                <div class="layui-form-item ">
                    <label class="layui-form-label" style="width: 150px;">金币数量</label>
                    <div class="layui-input-inline">
                        <input type="number" id="jinbi" name="jinbi" class="layui-input" oninput="if(value < 0 )value = 0" value="0"/>
                    </div>
                </div>
                <!-- <div class="layui-form-item ">
                    <label class="layui-form-label" style="width: 150px;">备注</label>
                    <div class="layui-input-inline">
                        <textarea id="jinbiRemark" name="jinbiRemark" class="layui-textarea"></textarea>
                    </div>
                </div> -->
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn layui-btn-normal  layui-btn-radius" onclick="addJinbi()">
                            &emsp;增加金币余额&emsp;
                        </button>
                        <button type="button" class="layui-btn layui-btn-danger layui-btn-radius" onclick="delJinbi()">
                            &emsp;扣除金币余额&emsp;
                        </button>
                    </div>
                </div>

                <fieldset class="layui-elem-field layui-field-title">
                    <legend><strong>钻石金额修改</strong></legend>
                </fieldset>
                <div class="layui-form-item ">
                    <label class="layui-form-label" style="width: 150px;">钻石数量</label>
                    <div class="layui-input-inline">
                        <input type="number" id="zuanshi" name="zuanshi" class="layui-input" oninput="if(value < 0 )value = 0"  value="0"/>
                    </div>
                </div>
                <!-- <div class="layui-form-item ">
                    <label class="layui-form-label" style="width: 150px;">备注</label>
                    <div class="layui-input-inline">
                        <textarea id="zuanshiRemark" name="zuanshiRemark" class="layui-textarea"></textarea>
                    </div>
                </div> -->
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn layui-btn-normal  layui-btn-radius" onclick="addZuanshi()">
                            &emsp;增加钻石余额&emsp;
                        </button>
                        <button type="button" class="layui-btn layui-btn-danger layui-btn-radius" onclick="delZuanshi()">
                            &emsp;扣除钻石余额&emsp;
                        </button>
                    </div>
                </div>
                <input id="formToken" name="formToken" type="hidden" value="${formToken!''}">
            </form>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['upload', 'form'], function () {
        let $ = layui.$;
        var form = layui.form;
        form.render();
        $.fn.extend({
            serializeObject: function () {
                var obj = {}; //声明一个对象
                $.each(this.serializeArray(), function (index, field) {
                    obj[field.name] = field.value; //通过变量，将属性值，属性一起放到对象中
                })
                return obj;
            }
        });
    });
    function addJinbi() {
        if (parseInt($("#jinbi").val()) < 1) {
            layer.msg("金币数量不能小于1", {icon: 2, time: 1000});
            return false;
        }
        // if ($("#jinbiRemark").val() === '') {
        //     layer.msg("请填写备注", {icon: 2, time: 1000});
        //     return false;
        // }

        layer.confirm('确认要增加金币余额吗？', function (index) {
            ajaxPost($, "/after/user/userJinUpdate", {
                userid: $("#id").val(),
                formToken: $("#formToken").val(),
                // jinbiRemark: $("#jinbiRemark").val(),
                leixng: 1,
                money: $("#jinbi").val()
            }, function (data) {
                if (data.code === 0) {
                    layer.msg("用户金币余额增加成功", {icon: 1, time: 2000});
                    setTimeout(function () {
                        location.reload();
                    }, 1000);
                } else {
                    layer.msg(data.msg, {icon: 2, time: 2000});
                }
            });
        })
       
    }
    function delJinbi() {
        if (parseInt($("#jinbi").val()) < 1) {
            layer.msg("金币数量不能小于1", {icon: 2, time: 1000});
            return false;
        }
        // if ($("#jinbiRemark").val() === '') {
        //     layer.msg("请填写备注", {icon: 2, time: 1000});
        //     return false;
        // }
        layer.confirm('确认要扣除金币余额吗？', function (index) {
            ajaxPost($, "/after/user/userJinUpdate", {
                userid: $("#id").val(),
                formToken: $("#formToken").val(),
                // jinbiRemark: $("#jinbiRemark").val(),
                leixng: 2,
                money: $("#jinbi").val()
            }, function (data) {
                if (data.code === 0) {
                    layer.msg("用户金币余额扣除成功", {icon: 1, time: 2000});
                    setTimeout(function () {
                        location.reload();
                    }, 1000);
                } else {
                    layer.msg(data.msg, {icon: 2, time: 2000});
                }
            })
        })

    }

    function addZuanshi() {
        if (parseInt($("#zuanshi").val()) < 1) {
            layer.msg("钻石数量不能小于1", {icon: 2, time: 1000});
            return false;
        }
        // if ($("#zuanshiRemark").val() === '') {
        //     layer.msg("请填写备注", {icon: 2, time: 1000});
        //     return false;
        // }
        layer.confirm('确认要增加钻石余额吗？', function (index) {
            ajaxPost($, "/after/user/userZuanUpdate", {
                userid: $("#id").val(),
                formToken: $("#formToken").val(),
                // zuanshiRemark: $("#zuanshiRemark").val(),
                leixng: 1,
                money: $("#zuanshi").val()
            }, function (data) {
                if (data.code === 0) {
                    layer.msg("用户钻石余额增加成功", {icon: 1, time: 2000});
                    setTimeout(function () {
                        location.reload();
                    }, 1000);
                } else {
                    layer.msg(data.msg, {icon: 2, time: 2000});
                }
            })
        })
    }
    function delZuanshi() {
        if (parseInt($("#zuanshi").val()) < 1) {
            layer.msg("钻石数量不能小于1", {icon: 2, time: 1000});
            return false;
        }
        // if ($("#zuanshiRemark").val() === '') {
        //     layer.msg("请填写备注", {icon: 2, time: 1000});
        //     return false;
        // }
        layer.confirm('确认要扣除钻石余额吗？', function (index) {
            ajaxPost($, "/after/user/userZuanUpdate", {
                userid: $("#id").val(),
                formToken: $("#formToken").val(),
                // zuanshiRemark: $("#zuanshiRemark").val(),
                leixng: 2,
                money: $("#zuanshi").val()
            }, function (data) {
                if (data.code === 0) {
                    layer.msg("用户钻石余额扣除成功", {icon: 1, time: 2000});
                    setTimeout(function () {
                        location.reload();
                    }, 1000);
                } else {
                    layer.msg(data.msg, {icon: 2, time: 2000});
                }
            })
        })

    }
</script>
</html>